Commentary for Bava Batra 1:5
כּוֹפִין אוֹתוֹ לִבְנוֹת בֵּית שַׁעַר וְדֶלֶת לֶחָצֵר. רַבָּן שִׁמְעוֹן בֶּן גַּמְלִיאֵל אוֹמֵר, לֹא כָל הַחֲצֵרוֹת רְאוּיוֹת לְבֵית שָׁעַר. כּוֹפִין אוֹתוֹ לִבְנוֹת לָעִיר חוֹמָה וּדְלָתַיִם וּבְרִיחַ. רַבָּן שִׁמְעוֹן בֶּן גַּמְלִיאֵל אוֹמֵר, לֹא כָל הָעֲיָרוֹת רְאוּיוֹת לְחוֹמָה. כַּמָּה יְהֵא בָעִיר וִיהֵא כְאַנְשֵׁי הָעִיר, שְׁנֵים עָשָׂר חֹדֶשׁ. קָנָה בָהּ בֵּית דִּירָה, הֲרֵי הוּא כְאַנְשֵׁי הָעִיר מִיָּד:
He [an occupant of a courtyard who does not wish to assist the others] is compelled to build a gate-house for the courtyard, [where the gate guard can sit in the shade and keep the passersby in the public domain from looking into the courtyard], and (he is compelled to build) a door [for the courtyard gate]. R. Shimon b. Gamliel says: Not all courtyards require a gate-house. [A courtyard not adjoining the public domain does not require a gate-house. The halachah is not in accordance with R. Shimon b. Gamliel. For even if it does not adjoin the public domain, sometimes there is a press of people and they converge upon the courtyard.] R. Shimon b. Gamliel says: Not all cities require a wall. [A city not close to the border of the enemy does not require a wall. The halachah is not in accordance with R. Shimon b. Gamliel. Even if it is not close to the border of the enemy, it requires a wall, for armed bands sometimes come there.] How long must someone be in a city to be regarded as one of its inhabitants [to share in community responsibilities]? Twelve months. [But nowadays, that there is greater movement, the customary period is thirty days.] If one bought a dwelling, he is immediately regarded as a city inhabitant.
Bartenura on Mishnah Bava Batra
English Explanation of Mishnah Bava Batra
They compel [a resident of the town to contribute to] the building of a wall for the town and double doors and a bolt. Rabban Shimon ben Gamaliel says: “Not every town is fit for a wall.”
How long must a man dwell in a town to count as one of the men of the town? Twelve months. If he has purchased a dwelling place he immediately counts as one of the men of the town.
Mishnah five deals with the obligation of a person who shares a courtyard with another to help in building certain parts of the courtyard. The second half of the mishnah deals with the obligations that residents of a town have to participate in the costs of building the public structures in the town.
Section one teaches that a person who holds joint possession of a courtyard can be compelled to share in the costs of building a gate-house (where a guard would sit and protect the homes attached to the courtyard) and a door. Since these are necessities of a courtyard, one must participate in their cost. Rabban Shimon ben Gamaliel points out that not all courtyards need a gate-house. Assumedly smaller courtyards can be protected without building a gate-house. Therefore, a person would be obligated to help pay for building a gate-house only as long as the courtyard was fit for one.
Section two discusses similar laws with regards to people who live in a town. Just as in modern society people pay taxes in order to pay for the building and upkeep of town property, so too in the times of the Mishnah people had to jointly pay for the building of a wall, double-doors and a bolt to help protect the town. Again Rabban Shimon ben Gamaliel points out that not all towns are fit for walls. If the town was not a one which would usually have a wall, the residents are not obligated to share in its costs.
Finally, section three discusses how long a person must dwell in the town in order to be an official resident and thereby be obligated to pay for building its wall. There are two criteria. First of all, if he dwells in the town for twelve months he is obligated to pay. Second, if he purchases property in the town, he is immediately obligated, even if he doesn’t dwell there.